package com.siyu.rehearsal.ttdimension.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import com.siyu.rehearsal.ttdimension.domain.Dimension;
import com.siyu.rehearsal.ttdimension.service.IDimensionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 二位水动力模型文件存储信息Controller
 *
 * @author hrhy
 * @date 2024-07-12
 */
@RestController
@RequestMapping("/system/dimension")
public class DimensionController extends BaseController
{
    @Autowired
    private IDimensionService dimensionService;

    /**
     * 查询二位水动力模型文件存储信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Dimension dimension)
    {
        startPage();
        List<Dimension> list = dimensionService.selectDimensionList(dimension);
        return getDataTable(list);
    }

    /**
     * 导出二位水动力模型文件存储信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dimension dimension)
    {
        List<Dimension> list = dimensionService.selectDimensionList(dimension);
        ExcelUtil<Dimension> util = new ExcelUtil<Dimension>(Dimension.class);
        util.exportExcel(response, list, "二位水动力模型文件存储信息数据");
    }

    /**
     * 获取二位水动力模型文件存储信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dimensionService.selectDimensionById(id));
    }

    /**
     * 新增二位水动力模型文件存储信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody Dimension dimension)
    {
        return toAjax(dimensionService.insertDimension(dimension));
    }

    /**
     * 修改二位水动力模型文件存储信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Dimension dimension)
    {
        return toAjax(dimensionService.updateDimension(dimension));
    }

    /**
     * 删除二位水动力模型文件存储信息
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dimensionService.deleteDimensionByIds(ids));
    }
}
